package com.nhh.v.controller

import java.{util ⇒ jul}
import javax.validation.Valid

import com.nhh.v.anotation.ValidateHeader
import com.nhh.v.dto.RequiredRequestHeader
import com.nhh.v.service.HomeService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation._
import reactor.core.publisher.Mono

/**
  * Created by ywp on 2018/9/4.
  */
@RestController
@RequestMapping(path = Array("/api/home"))
@Validated
class HomeController(@Autowired val homeService: HomeService) {


  @PostMapping(path = Array("getMainData"))
  def getMainData(@Valid @ValidateHeader requireHeader: RequiredRequestHeader,
                  @RequestParam(value = "psize", required = false, defaultValue = "20") pSize: String,
                  @RequestParam(value = "pindex", required = false, defaultValue = "0") pIndex: String
                 ): Mono[_] = {
    Mono.just(homeService.getMainData(requireHeader.getUid, pIndex, pSize))
  }

}
